module.exports = function ($resource, $state, $http, $q, $scope, FileUploader, $modal, toaster, $stateParams) {
    $scope.getCompanyInfo = function () {
        $resource('/api/ac/ggc/reviewCompanyService/getApplyCompanyInfo', {}, {}).save({}, function(res){
            if(res.errcode != 0){ 
                toaster.error({title:"",body:res.errmsg});
                return;
            }
            console.log('查询企业信息是否完整');
            console.log(res);
            if (res.data.msg == '0') {
              if (confirm('请先完善企业信息')) {
                $state.go('app.completeinfo');
              } else {
                $state.go('app.completeinfo');
              }
            }
        });
    }
    $scope.getCompanyInfo();
    $scope.type = $stateParams.type;
    var url = '';
    if ($scope.type == '0'){
      url = '/api/as/ggc/reviewCompanyProject/findBackList';
    } else if ($scope.type == '1'){
      url = '/api/as/ggc/reviewCompanyProject/findUpdateList';
    }
      /* 分页
    * ========================================= */
    $scope.maxSize = 5;             //最多显示多少个按钮
    $scope.bigCurrentPage = 1;      //当前页码
    $scope.itemsPerPage = 10         //每页显示几条
    $scope.searchform = {};
    $scope.getlist = function () {
        var para = {
            pageNo:$scope.bigCurrentPage,
            pageSize:$scope.itemsPerPage,
        };
        para = angular.extend($scope.searchform, para);
        $resource(url, {}, {}).save(para, function(res){
            if(res.errcode != 0){
              toaster.error({title:"",body:res.errmsg});
              return;
            }
            $scope.objs = res.data.results;
            $scope.totalItems = res.data.totalRecord;
        });
        
    };
    $scope.getlist();

    $scope.toinfo= function (info) {
      if ($scope.type == '0'){
        $scope.flag = 'revokeproject';
        var modalInstance = $modal.open({
          template: require('../views/projectRevokeInfo.html'),
          controller: 'projectRevokeInfo',
          size: 'lg',
          resolve: {
            items: function () {
              return info;
            },
            flag: function () {
              return $scope.flag;
            },
            type: function () {
              return $scope.type;
            }
          }
        });
        modalInstance.result.then(function (showResult) {	
            $scope.getlist();
        });	
      } else if ($scope.type == '1'){
        $scope.flag = 'editproject';	
        var modalInstance = $modal.open({
          template: require('../views/projectedit.html'),
          controller: 'projectedit',
          size: 'lg',
          resolve: {
            items: function () {
              return info;
            },
            flag: function () {
              return $scope.flag;
            },
            type: function () {
              return $scope.type;
            }
          }
        });
        modalInstance.result.then(function (showResult) {	
            $scope.getlist();
        });
      }
    }
    // 驳回依据
    $scope.dismiss = function(info){
      $scope.flag = 'xmxgbh';
      var modalInstance = $modal.open({
        template: require('../views/dissmiss_info.html'),
        controller: 'dissmiss_info',
        size: 'xs',
        resolve: {
          items: function () {
            return info;
          },
          flag: function () {
            return $scope.flag;
          },
          type: function () {
            return $scope.type;
          }
        }
      });
      modalInstance.result.then(function (showResult) {	
          $scope.getlist();
      });
    }




}
